<template>
    <div>
        <h1>添加课程</h1>
        <br>
        <input type="text" v-model="title" placeholder="课程标题">
        <br>
        <input type="text" v-model="content" placeholder="课程内容">
        <br>
        <button @click="addcourse">添加</button>
    </div>
</template>

<script>
export default {
    data:function(){
        return{
            title:"",
            content:""
        }
    },
    methods:{
        addcourse:function(){
            let formData = new FormData();
            formData.append('title',this.title);
            formData.append('content',this.content)

            this.axios({
                url:"http://127.0.0.1:8000/addcourse/",
                method:'post',
                data:formData
            }).then((res)=>{
                if(res.data.code==200){
                    alert(res.data.message);
                }else{
                    alert(res.data.message)
                }
            })
        }
    }
}
</script>
